import { request } from '@umijs/max';
import type { SortOrder } from 'antd/es/table/interface';

export interface OrderItem {
  id: number;
  orderNo: string;
  customerName: string;
  productName: string;
  quantity: number;
  totalPrice: number;
  status: string;
  createTime: string;
  address: string;
  phone: string;
}

export async function OrderList(params: {
  current?: number;
  pageSize?: number;
  sortField?: string;
  sortOrder?: SortOrder;
}) {
  return request('/api/order', {
    method: 'GET',
    params,
  });
}

export async function addOrder(data: Omit<OrderItem, 'id'>) {
  return request('/api/order/add', {
    method: 'POST',
    data,
  });
}

export async function updateOrder(data: OrderItem) {
  return request('/api/order/update', {
    method: 'POST',
    data,
  });
}

export async function deleteOrder(id: number) {
  return request('/api/order/delete', {
    method: 'POST',
    data: { id },
  });
} 